<template>
  <div class="worktask-designer-taskinfo-container">
    <el-dialog v-model="showDialog.order" title="合同信息" width="1300px">
      <order-input ref="orderRef" />
    </el-dialog>
    <el-dialog v-model="showDialog.product" title="业务产品信息" width="1300px">
      <product-list ref="productRef" />
    </el-dialog>
    <el-dialog v-model="showDialog.gift" title="赠品信息" width="1300px">
      <gift-list ref="giftListRef" />
    </el-dialog>
    <el-dialog v-model="showDialog.shop" title="店铺/账号信息" width="1300px">
      <shop-list ref="shopRef" />
    </el-dialog>
    <el-dialog v-model="showDialog.payment" title="收款信息" width="1300px">
      <payment-list ref="paymentRef" />
    </el-dialog>
    <el-dialog v-model="showDialog.invoicing" title="开票信息" width="1300px">
      <invoicing-list ref="invoicingListRef" />
    </el-dialog>
    <el-row :gutter="15">
      <el-col :span="6">
        <el-card shadow="hover">
          <template #header>
            <el-descriptions
              class="margin-top"
              title="客户信息"
              :column="3"
              :size="size"
              border
            >
              <template #extra>
                <el-button
                  class="card-header-tag"
                  type="success"
                  size="small"
                  @click="CustomerHandle"
                >
                  更多详情
                </el-button>
              </template>
            </el-descriptions>
          </template>
          <div>
            <!-- <p>
              <el-text style="color: #999">客户简称：</el-text>
              <el-text style="color: #333">三利毛巾</el-text>
            </p> -->
            <p>
              <el-text style="color: #999">客户全称：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.CustomerAllName }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">所属区域：</el-text>
              <el-text style="color: #333">{{ CustomerInfo.CityShow }}</el-text>
            </p>
            <p>
              <el-text style="color: #999">地址：</el-text>
              <el-text style="color: #333">{{ CustomerInfo.Address }}</el-text>
            </p>
            <p>
              <el-text style="color: #999">电话：</el-text>
              <el-text style="color: #333">{{ CustomerInfo.Telphone }}</el-text>
            </p>
            <p>
              <el-text style="color: #999">负责人：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.LegalPerson }} {{ CustomerInfo.LegalMobile }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">业务联系人：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.BusinessPerson }}
                {{ CustomerInfo.BusinessPersonMobile }}
              </el-text>
            </p>
          </div>
          <el-divider />
          <div>
            <p>
              <el-text style="color: #999">客户所在行业：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.IndustryShow }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">主营产品：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.SalesProducts }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">主要销售区域：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.SalesArea }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">主要客户群体：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.CustomerGroup }}
              </el-text>
            </p>
          </div>
        </el-card>
        <el-card shadow="hover">
          <template #header>
            <el-descriptions
              class="margin-top"
              title="签单业务销售人员信息"
              :column="3"
              :size="size"
              border
            >
              <!-- <template #extra>
                <el-tag class="card-header-tag" type="success">
                  查看商机跟进记录
                </el-tag>
              </template> -->
            </el-descriptions>
          </template>
          <div>
            <p>
              <el-text style="color: #999">员工工号：</el-text>
              <el-text style="color: #333">{{ StaffInfo.LoginName }}</el-text>
            </p>
            <p>
              <el-text style="color: #999">部门：</el-text>
              <el-text
                v-for="(item, index) in StaffInfo.Company"
                :key="index"
                style="color: #333"
              >
                [{{ item.CompanyName }}]
              </el-text>
              <el-text
                v-for="(item, index) in StaffInfo.Department"
                :key="index"
                style="color: #333"
              >
                [{{ item.DepartmentName }}]
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">签单人姓名：</el-text>
              <el-text style="color: #333">
                {{ StaffInfo.StaffName }} {{ StaffInfo.Mobile }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">主管：</el-text>
              <el-text style="color: #333">
                {{ StaffInfo.GroupStaff?.StaffName }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">经理：</el-text>
              <el-text style="color: #333">
                {{ StaffInfo.ManageStaff?.StaffName }}
              </el-text>
            </p>
          </div>
        </el-card>
        <el-card shadow="hover">
          <template #header>
            <el-descriptions
              class="margin-top"
              title="合同流程进度"
              :column="3"
              :size="size"
              border
            />
          </template>
          <el-timeline style="max-width: 600px">
            <el-timeline-item
              v-for="(activity, index) in activities"
              :key="index"
              type="primary"
              :hollow="true"
              :timestamp="activity.addTime"
            >
              {{ activity.OrderFlowName }}
            </el-timeline-item>
          </el-timeline>
        </el-card>
      </el-col>
      <el-col :span="18">
        <el-card shadow="hover">
          <el-button type="primary" plain @click="handleShow(1)">
            查看合同信息
          </el-button>
          <el-button type="primary" plain @click="handleShow(2)">
            查看业务产品信息
          </el-button>
          <el-button type="primary" plain @click="handleShow(3)">
            查看赠品信息
          </el-button>
          <el-button type="primary" plain @click="handleShow(4)">
            查看店铺/账号信息
          </el-button>
          <el-button type="primary" plain @click="handleShow(5)">
            查看收款信息
          </el-button>
          <el-button type="primary" plain @click="handleShow(6)">
            查看开票信息
          </el-button>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="合同任务信息"
            :column="3"
            :size="size"
            border
          >
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">合同编号</div>
              </template>
              {{ OrderInfo.OrderCode }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">业务类型</div>
              </template>
              <el-tag size="small">
                {{ OrderInfo.BusinessOrderName }}
              </el-tag>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">业务产品</div>
              </template>
              {{ WorktaskInfo.ProductName }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">服务对象(店铺信息)</div>
              </template>
              <el-tag size="small">
                <a :href="WorktaskInfo.StoreUrl" target="_blank">
                  {{ WorktaskInfo.BindStoreAccount }}
                </a>
              </el-tag>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">分单/派单人</div>
              </template>
              {{ WorktaskInfo.AssignStaffName }}
            </el-descriptions-item>

            <el-descriptions-item>
              <template #label>
                <div class="cell-item">接单人</div>
              </template>
              {{ WorktaskInfo.TaskStaffName }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">相关账密</div>
              </template>
              <el-tag
                v-if="WorktaskInfo.BindID != 0"
                size="small"
                @click="viewPassword(WorktaskInfo, true)"
              >
                账密查看
                <!-- {{ WorktaskInfo.StorePassword }} -->
              </el-tag>
              <el-tag v-else size="small">未补全</el-tag>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">计划服务期限</div>
              </template>
              <div>
                {{ WorktaskInfo?.OrderList?.PlanServiceStartDate }}至
                {{ WorktaskInfo?.OrderList?.PlanServiceEndDate }}
              </div>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">实际服务期限</div>
              </template>
              <div style="display: flex; align-items: center">
                <div
                  v-if="
                    WorktaskInfo.OrderList?.ServiceStartDate &&
                    WorktaskInfo.OrderList?.ServiceEndDate
                  "
                >
                  {{ WorktaskInfo.OrderList?.ServiceStartDate }}至
                  {{ WorktaskInfo.OrderList?.ServiceEndDate }}
                </div>

                <el-button
                  type="primary"
                  style="margin-left: 10px"
                  @click="realityEdit"
                >
                  设置
                </el-button>
              </div>
            </el-descriptions-item>
          </el-descriptions>
        </el-card>
        <el-card shadow="hover" :content-editable="false">
          <!-- <vab-query-form>
            <vab-query-form-left-panel :span="24">
              <el-form :inline="true" :model="queryForm" @submit.prevent>
                <el-space wrap :size="size">
                  <el-form-item>
                    <el-input
                      v-model.trim="queryForm.title"
                      clearable
                      placeholder="请输入任务内容"
                    />
                  </el-form-item>
                  <el-form-item>
                    <el-date-picker
                      v-model="value1"
                      type="date"
                      placeholder="请选择实际完成日期"
                    />
                  </el-form-item>
                  <el-form-item>
                    <el-input
                      v-model.trim="queryForm.OrderCode"
                      clearable
                      placeholder="业绩审核状态"
                    />
                  </el-form-item>
                  <el-form-item>
                    <el-date-picker
                      v-model="value1"
                      type="date"
                      placeholder="请选择计划交付时间"
                    />
                  </el-form-item>
                  <el-form-item>
                    <el-button :icon="Search" type="primary" @click="queryData">
                      查询
                    </el-button>
                  </el-form-item>
                </el-space>
              </el-form>
            </vab-query-form-left-panel>
          </vab-query-form> -->
          <el-descriptions
            class="margin-top"
            title="任务清单"
            :column="3"
            :size="size"
            border
          >
            <template #extra>
              <el-button type="primary" @click="allSubmitFinish">
                整单提交完成
              </el-button>
            </template>
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="WorktaskList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              show-overflow-tooltip
              type="selection"
            />
            <el-table-column
              align="center"
              label="清单ID"
              prop="WorkTaskListID"
              show-overflow-tooltip
              width="80"
            />
            <el-table-column
              align="left"
              label="任务内容"
              prop="WorkTaskName"
              show-overflow-tooltip
              width="160"
            />
            <el-table-column
              align="center"
              label="计划数量"
              prop="WorkTaskNum"
              show-overflow-tooltipwidth="80"
            />
            <el-table-column
              align="center"
              label="单位"
              prop="WorkTaskUnit"
              show-overflow-tooltip
              width="60"
            />
            <el-table-column
              align="center"
              label="备注"
              prop="WorkTaskMemo"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="计划交付"
              prop="PlanFinishDate"
              show-overflow-tooltip
              width="120"
            />
            <!-- <el-table-column
              align="center"
              label="实际完成日期"
              prop="FinishDate"
              show-overflow-tooltip
            /> -->
            <el-table-column align="center" label="实际完成日期" width="140">
              <template #default="{ row }">
                <el-date-picker
                  v-model="row.FinishDate"
                  :disabled="row.TaskState"
                  :disabled-date="disabledDate"
                  type="date"
                  placeholder="选择日期"
                  size="small"
                  value-format="YYYY-MM-DD"
                  style="width: 120px"
                />
              </template>
            </el-table-column>
            <!-- <el-table-column
              align="center"
              label="实际数量"
              prop="FinishNum"
              show-overflow-tooltip
            /> -->
            <el-table-column align="center" label="实际完成数量" width="130">
              <template #default="{ row }">
                <el-input-number
                  v-model="row.FinishNum"
                  size="small"
                  :min="-1"
                  :max="row.WorkTaskNum"
                  :disabled="row.TaskState"
                  style="width: 100px"
                />
              </template>
            </el-table-column>
            <el-table-column align="center" label="计划金额" width="80">
              <template #default="{ row }">
                {{ row.TichengMoney }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="实际金额" width="80">
              <template #default="{ row }">
                <span color="red">{{ row.FinishTichengMoney }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="业绩审核状态"
              prop="SubmitCheckState"
              width="120"
            >
              <template #default="{ row }">
                <el-tooltip
                  v-if="row.SubmitCheckState === -1"
                  class="box-item"
                  effect="dark"
                  :content="row.SubmitCheckMemo"
                  placement="top"
                >
                  <div>未通过</div>
                </el-tooltip>
                <div
                  v-if="
                    row.SubmitCheckState === 0 || row.SubmitCheckState == null
                  "
                >
                  未审核
                </div>
                <div v-if="row.SubmitCheckState === 2">审核通过</div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="isTaskState != 0"
              align="center"
              label="操作"
              fixed="right"
              width="110"
            >
              <template #default="{ row }">
                <el-button
                  v-if="row.TaskState == 0"
                  type="primary"
                  size="small"
                  @click="handleEdit(row)"
                >
                  完成提交
                </el-button>
                <el-button
                  v-if="row.TaskState == 1"
                  type="warning"
                  size="small"
                  @click="handleEdit(row)"
                >
                  已提交完成
                </el-button>
                <el-button
                  v-if="row.TaskState == -1"
                  type="danger"
                  size="small"
                  @click="handleEdit(row)"
                >
                  审核未通过
                </el-button>
                <el-button
                  v-if="row.TaskState == 2"
                  type="success"
                  size="small"
                  @click="handleEdit(row, 1)"
                >
                  已审核通过
                </el-button>
                <el-button v-if="row.TaskState == -4" type="info" size="small">
                  已作废
                </el-button>
              </template>
            </el-table-column>
            <el-table-column v-else align="center" label="操作">
              请先接单
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
    <workedit ref="workEditRef" :key="componentKey" @fetch-data="fetchData" />
    <customer ref="customerRef" @fetch-data="fetchData" />

    <!-- 设置实际服务期限 -->
    <order-service-date ref="orderServiceDateRef" @fetch-data="fetchData" />

    <domain ref="domainRef" />
    <host ref="hostRef" />
    <server ref="serverRef" />
    <email ref="emailRef" />
    <website ref="websiteRef" />
    <StoreLink ref="storeLinkRef" />
  </div>
</template>

<script>
  import OrderServiceDate from '@/views/business/components/OrderServiceDate'

  import Domain from '@/views/business/components/Domain'
  import Host from '@/views/business/components/Host'
  import Server from '@/views/business/components/Server'
  import Email from '@/views/business/components/Email'
  import Website from '@/views/business/components/Website'
  import StoreLink from '@/views/business/components/StoreLink'

  import OrderInput from '@/views/business/components/OrderInput'
  import ProductList from '@/views/business/components/ProductList'
  import GiftList from '@/views/business/components/GiftList'
  import ShopList from '@/views/business/components/ShopList'
  import PaymentList from '@/views/business/components/PaymentList'
  import InvoicingList from '@/views/business/components/InvoicingList'

  import { showPassword } from '@/api/businessOrder'
  import { allSubmitFinishSave } from '@/api/worktask'
  import { getOperateDetails } from '@/api/storeDetails'
  import Workedit from '@/views/business/components/WorkTaskinfoEdit'
  import { Delete, Plus, Search } from '@element-plus/icons-vue'
  import Customer from '@/views/business/components/Customer'

  export default defineComponent({
    name: 'WorktaskDesignerTaskinfo',
    components: {
      OrderServiceDate,
      StoreLink,
      Domain,
      Host,
      Server,
      Email,
      Website,
      Workedit,
      Customer,
      OrderInput,
      ProductList,
      GiftList,
      ShopList,
      PaymentList,
      InvoicingList,
    },

    setup() {
      const route = useRoute()
      const $baseConfirm = inject('$baseConfirm')
      const $baseMessage = inject('$baseMessage')

      const state = reactive({
        InvoicingList: [],
        PaymentList: [],
        StoreList: [],
        GiftList: [],
        ProductList: [],
        activities: [],
        orderServiceDateRef: null,
        storeLinkRef: null,
        websiteRef: null,
        emailRef: null,
        hostRef: null,
        serverRef: null,
        domainRef: null,
        showDialog: {
          order: false,
          product: false,
          gift: false,
          shop: false,
          payment: false,
          invoicing: false,
        },
        orderRef: null,
        productRef: null,
        giftListRef: null,
        shopRef: null,
        dialogFormVisible: false,
        SeviceDates: '',
        paymentRef: null,
        invoicingListRef: null,
        customerRef: null,
        componentKey: 0,
        isTaskState: 0,
        workEditRef: null,
        orderAssignRef: null,
        serviceEditRef: null,
        storeEditRef: null,
        listLoading: true,
        layout: 'total, sizes, prev, pager, next, jumper',
        selectRows: '',
        queryForm: {
          OrderID: 0,
          pageNo: 1,
          pageSize: 10,
          title: '',
        },
        OrderInfo: [],
        WorktaskInfo: [],
        WorktaskList: [],
        ServiceRecordList: [],
        StoreSeviceRecordList: [],
        StoreActLog: [],
        CustomerInfo: {},
        StaffInfo: {},
      })

      const setSelectRows = (val) => {
        state.selectRows = val
      }

      const handleEdit = (row, num) => {
        console.log(row, '12312312312')
        state.workEditRef.showEdit(row, num, state.WorktaskInfo.TaskCheckerList)
      }
      const CustomerHandle = () => {
        state.customerRef.showEdit(state.CustomerInfo)
      }
      const allSubmitFinish = () => {
        console.log('state.selectRows', state.selectRows)
        if (state.selectRows.length > 0) {
          $baseConfirm('你确定要批量提交选中项吗', null, async () => {
            const { msg } = await allSubmitFinishSave({
              SubmitFinishSelect: state.selectRows,
            })
            $baseMessage(msg, 'success', 'vab-hey-message-success')
            await fetchData()
          })
        } else {
          $baseMessage('未选中任何行', 'error', 'vab-hey-message-error')
        }
      }
      const handleSizeChange = (val) => {
        state.queryForm.pageSize = val
        fetchData()
      }
      const handleCurrentChange = (val) => {
        state.queryForm.pageNo = val
        fetchData()
      }
      const queryData = () => {
        state.queryForm.pageNo = 1
        fetchData()
      }
      const fetchData = async () => {
        state.componentKey++
        state.listLoading = true
        const {
          data: {
            OrderFlow,
            OrderInfo,
            WorktaskInfo,
            WorktaskList,
            ServiceRecordList,
            StoreSeviceRecordList,
            StoreActLog,
            CustomerInfo,
            StaffInfo,
            ProductList,
            GiftList,
            StoreList,
            PaymentList,
            InvoicingList,
          },
        } = await getOperateDetails(state.queryForm)
        state.InvoicingList = InvoicingList
        state.PaymentList = PaymentList
        state.StoreList = StoreList
        state.GiftList = GiftList
        state.ProductList = ProductList
        state.activities = OrderFlow
        state.OrderInfo = OrderInfo
        state.WorktaskInfo = WorktaskInfo
        state.WorktaskList = WorktaskList
        state.ServiceRecordList = ServiceRecordList
        state.StoreSeviceRecordList = StoreSeviceRecordList
        state.StoreActLog = StoreActLog
        state.CustomerInfo = CustomerInfo
        state.StaffInfo = StaffInfo
        state.ServiceRecordList = ServiceRecordList
        state.listLoading = false
      }

      const handleShow = (t) => {
        if (t == 1) {
          state.showDialog.order = true
          nextTick(() => {
            state.orderRef.showOrder(state.OrderInfo)
          })
        }
        if (t == 2) {
          state.showDialog.product = true
          console.log(
            'state.OrderInfo, state.ProductList',
            state.OrderInfo,
            state.ProductList
          )
          nextTick(() => {
            state.productRef.showList(state.OrderInfo, state.ProductList)
          })
        }
        if (t == 3) {
          state.showDialog.gift = true
          nextTick(() => {
            state.giftListRef.showList(state.OrderInfo, state.GiftList)
          })
        }
        if (t == 4) {
          state.showDialog.shop = true
          nextTick(() => {
            state.shopRef.showList(state.OrderInfo, state.StoreList)
          })
        }
        if (t == 5) {
          state.showDialog.payment = true
          nextTick(() => {
            state.paymentRef.showList(state.OrderInfo, state.PaymentList)
          })
        }
        if (t == 6) {
          state.showDialog.invoicing = true
          nextTick(() => {
            state.invoicingListRef.showList(
              state.OrderInfo,
              state.InvoicingList
            )
          })
        }
      }

      const disabledDate = (time) => {
        return time.getTime() > Date.now() // 8.64e7 毫秒数代表一天
      }

      watch(route, (newVal, oldValue) => {
        console.log(newVal, oldValue, '12312312')
        if (newVal.query.OrderID) {
          state.queryForm.OrderID = route.query.OrderID
          state.queryForm.WorkTaskID = route.query.WorkTaskID
          state.isTaskState = route.query.isTaskState
          fetchData()
        }
      })

      const viewPassword = async (row, disabled) => {
        console.log('shopLinkForm', row)
        const businessClass = row.OrderList.BusinessClassID
        // state.BusinessClassID = row.BusinessClassID
        switch (businessClass) {
          case 1:
            if (row.BindID != 0) {
              if (await open()) {
                state.storeLinkRef.showEdit(row, true, disabled)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, disabled)
            }
            break
          case 2:
            if (row.BindID != 0) {
              if (await open()) {
                state.storeLinkRef.showEdit(row, true, disabled)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, disabled)
            }
            break
          case 3:
            if (row.BindID != 0) {
              if (await open()) {
                state.storeLinkRef.showEdit(row, true, disabled)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, disabled)
            }
            break
          case 4:
            if (row.BindID != 0) {
              if (await open()) {
                state.storeLinkRef.showEdit(row, true, disabled)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, disabled)
            }
            break
          case 5:
            if (row.OrderList.ProductID == 63) {
              if (row.BindID != 0) {
                if (await open()) {
                  state.domainRef.showEdit(row, true, disabled)
                }
              } else {
                state.domainRef.showEdit(row, false, disabled)
              }
            } else if (row.OrderList.ProductID == 64) {
              if (row.BindID != 0) {
                if (await open()) {
                  state.hostRef.showEdit(row, true, disabled)
                }
              } else {
                state.hostRef.showEdit(row, false, disabled)
              }
            } else if (row.OrderList.ProductID == 65) {
              if (row.BindID != 0) {
                if (await open()) {
                  state.serverRef.showEdit(row, true, disabled)
                }
              } else {
                state.serverRef.showEdit(row, false, disabled)
              }
            } else if (row.OrderList.ProductID == 67) {
              if (row.BindID != 0) {
                if (await open()) {
                  state.emailRef.showEdit(row, true, disabled)
                }
              } else {
                state.emailRef.showEdit(row, false, disabled)
              }
            } else if (
              row.OrderList.ProductID == 68 ||
              row.OrderList.ProductID == 69 ||
              row.OrderList.ProductID == 70 ||
              row.OrderList.ProductID == 107 ||
              row.OrderList.ProductID == 108
            ) {
              if (row.BindID != 0) {
                if (await open()) {
                  state.websiteRef.showEdit(row, true, disabled)
                }
              } else {
                state.websiteRef.showEdit(row, false, disabled)
              }
            } else {
              if (row.BindID != 0) {
                if (await open()) {
                  state.storeLinkRef.showEdit(row, true, disabled)
                }
              } else {
                state.storeLinkRef.showEdit(row, false, disabled)
              }
            }
            break
          default:
            if (row.BindID != 0) {
              if (await open()) {
                state.storeLinkRef.showEdit(row, true, disabled)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, disabled)
            }
        }
        // 域名的63
        // state.domainRef.showEdit(row)
        // 主机的64
        // state.hostRef.showEdit(row)
        // 邮箱的67
        // state.emailRef.showEdit(row)
        // 网站 68,69,70,107.108
        // state.websiteRef.showEdit(row)
      }

      const open = async () => {
        let flag
        await ElMessageBox.prompt('请输入密码', '', {
          confirmButtonText: '确认',
          cancelButtonText: '关闭',
        })
          .then(async ({ value }) => {
            const dataMsg = {
              StoreID: state.WorktaskInfo.StoreID,
              ShowPassword: value,
            }
            const { data } = await showPassword(dataMsg)
            console.log(data, typeof data)

            if (data) {
              flag = true
            } else {
              flag = false
              ElMessage({
                type: 'warning',
                message: `密码输入错误`,
              })
            }
          })
          .catch(() => {
            flag = false
          })
        return flag
      }

      // 设置实际服务时间
      const realityEdit = () => {
        state.SeviceDates = [
          state.WorktaskInfo.OrderList.ServiceStartDate,
          state.WorktaskInfo.OrderList.ServiceEndDate,
        ]
        state.orderServiceDateRef.showEdit(
          state.WorktaskInfo,
          state.SeviceDates
        )
        console.log(state.SeviceDates, '实际服务时间')
      }

      onMounted(() => {
        console.log('触发这里了吗?')
        state.queryForm.OrderID = route.query.OrderID
        state.queryForm.WorkTaskID = route.query.WorkTaskID
        state.isTaskState = route.query.isTaskState
        fetchData()
      })
      provide('rootMethods', { fetchData })
      provide('tootMethods', { fetchData })

      return {
        ...toRefs(state),
        setSelectRows,
        handleEdit,
        handleSizeChange,
        handleCurrentChange,
        realityEdit,
        queryData,
        handleShow,
        viewPassword,
        open,
        fetchData,
        CustomerHandle,
        Delete,
        Plus,
        Search,
        allSubmitFinish,
        disabledDate,
      }
    },
  })
</script>
